package org.example;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Test1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        for (int i = 0; i < count; i++) {
            String s = scanner.next();
            Set<Character> set = new HashSet<>();
            int ret = 0;
            if (s.length() <= 26) {
                for (char c : s.toCharArray()) {
                    if (ret >= 26) {
                        ret++;
                    }else {
                        if (set.contains(c)) {
                            ret++;
                            set.remove(c);
                        }else {
                            set.add(c);
                        }
                    }
                }
            }else {
                while (s.length() > 26) {

                }
            }
            System.out.println(ret);
        }
    }
}
